<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <style>
html, body {
  width: 100%;
  height: 0%;
}
#paper {
  width: 50%;
  height: 37.5%;
}
  </style>
  <script src="/js/spritejs.js"></script>
</head>
<body>
  <div id="paper"></div>
  <script>
const paper = new spritejs.Scene('#paper', {
  viewport: 'auto',
  resolution: 'flex',
})
//paper.setResolution(800, 600)

const sprite = new spritejs.Sprite()
sprite.attr({
  bgcolor: '#000',
  pos: [10, 10],
  size: [100, 100],
})
let i = 0
sprite.on('afterdraw', evt => {
  const context = evt.context
  context.font = '48px Arial'
  context.strokeStyle = '#f00'
  context.strokeText(String(++i), 10, 90)  
})
paper.layer().appendChild(sprite)

setInterval(() => {
  sprite.forceUpdate(true)
}, 1000)
  </script>
</body>
</html>